<?php
//echo 'aaaaaaa';
include_once(PATH_SQL . 'attribute_detail_sql.php');
include_once(PATH_MODEL . 'attribute_detail_model.php');
include_once(PATH_VIEW_ADMIN . 'attribute_detail_view.php');
$oModelAttribute_detail=new Db_attribute_detail();
$oViewAttribute_detail = new View_Attribute_detail($oModelAttribute_detail);
$oModelAttribute_detail->setData('page_size',50);
$oModelAttribute_detail->setData('pagegroup_size',5);
$oModelAttribute_detail->setData('stylesheet',"paging");
$sAction=$_REQUEST['sAction'];

//print_r($sAction);
switch($sAction)
{
	case '':
		{
			unset($_SESSION['fromDate']);
			unset($_SESSION['toDate']);
			$oViewAttribute_detail->displayManagerIndex($oModelAttribute_detail);
			$oViewAttribute_detail->displayListAttribute($oModelAttribute_detail);
			$oViewAttribute_detail->displayNameAttribute($oModelAttribute_detail);  
			break;
		}
		
		case 'do_delete':
        {
          $oModelAttribute_detail->setData('atd_id', $oModelAttribute_detail->getData('id'));
            $result_del = $oModelAttribute_detail->deleteAttribute();
           redir('?sMod=attribute_detail.index');
          
        }
		case 'edit_form':
        {
			$oViewAttribute_detail->displayManagerIndex($oModelAttribute_detail);
		      	
            $oModelAttribute_detail->setData('atd_id', $oModelAttribute_detail->getData('id'));
			
			//print_r($_GET['id']);
			//var_dump($_POST); die();
			$oViewAttribute_detail->displayInfoAttribute_update($oModelAttribute_detail);	
			$result_del = $oModelAttribute->update_att($_GET['id'],$_POST['name_attri'],$_POST['txtname'],$_POST['chk_status']);				
			$oViewAttribute_detail->displayListAttribute($oModelAttribute_detail); 
			$oViewAttribute_detail->displayNameAttribute($oModelAttribute_detail);   
			if($_REQUEST['sActionEdit'] == '1')
					redir('?sMod=attribute_detail.index&status=true');
			//
			/*if(!$result_del)
			redir('?sMod=attribute.index&status=fall');
			else
			redir('?sMod=attribute.index&status=success');*/
			break;
		}
		case 'add_form':
		{
		
			$oViewAttribute_detail->displayManagerIndex($oModelAttribute_detail);
			if ($_POST['atd_name']!='')
			{
				//$result_del = $oModelAttribute_detail->insert_att($_POST['at_id'],$_POST['atd_name'],$_POST['atd_status']);	
				 $check_insert = $oModelAttribute_detail->insert_att();
				 if($check_insert)
				 {
				 	redir('?sMod=attribute_detail.index&status=new&status=success');
				 }
				 else
				 {
					 redir('?sMod=attribute_detail.index&status=new&status=fall');
				 }
			}
			
			$oViewAttribute_detail->displayListAttribute($oModelAttribute_detail);  
			$oViewAttribute_detail->displayInforAttribute_insert($oModelAttribute_detail);
			$oViewAttribute_detail->displayNameAttribute($oModelAttribute_detail);  
			
			if($_REQUEST['sActionEdit'] == '1')
					redir('?sMod=attribute_detail.index&status=new');
		}
		
}

$oViewAttribute_detail->displayPage($oModelAttribute_detail);
?>